{% load static %}
{% load bootstrap4 %}
{% load i18n %}

{% get_current_language as language_code %}

<!DOCTYPE html>
<html lang="{{ en }}">
<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="An example of Django project with basic user functionality.">
    <meta name="author" content="Yehor Smoliakov">

    <link rel="icon" href="{% static 'favicon.ico' %}">

    <title>{% block title %}template{% endblock %}</title>

    <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/styles.css' %}" rel="stylesheet">

</head>

<body>

<nav class="navbar navbar-expand-md navbar-dark bg-dark static-top">

    <a class="navbar-brand" href="/">{% trans 'Home' %}</a>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
                {% if log_in %}
                <li class="nav-item">
                    <a class="nav-link" href="{% url 'users:login_username' %}">{{log_in}}</a>
                </li>
            {% endif %}
                <li class="nav-item">
                    {% if log_out == "注销" %}
                    <a class="nav-link" href="{% url 'users:logout' %}">{{log_out}}</a>
                    {% else %}
                    <a class="nav-link" href="{% url 'users:register' %}">注册</a>
                    {% endif %}
                </li>

        </ul>

    </div>

</nav>

<div class="container-fluid mt-3">

    {% bootstrap_messages %}

    {% block content %}
        No content.
    {% endblock %}

</div>

<script src="{% static 'vendor/jquery/jquery-3.4.1.min.js' %}"></script>
<script src="{% static 'vendor/popper/popper.min.js' %}"></script>
<script src="{% static 'vendor/bootstrap/js/bootstrap.min.js' %}"></script>

<script src="{% static 'js/ie10-viewport-bug-workaround.js' %}"></script>

</body>
</html>
<script src="https://cdn.bootcss.com/jquery/1.12.3/jquery.min.js">
</script>
<script>
 //点击刷新验证码
 $(function () {
 $('.captcha').css({
 'cursor': 'pointer'
 });
 // ajax刷新
 $('.captcha').click(function () {
 console.log('click');
 $.get("/captcha/refresh/",
 function (result) {
 $('.captcha').attr('src', result['image_url']);
 $('#id_captcha_0').val(result['key'])
 });
 });
 $('.btn btn-primary').click(function () {
 console.log('click');
 $.get("/captcha/refresh/",
 function (result) {
 $('.btn btn-primary').attr('src', result['image_url']);
 $('#id_captcha_0').val(result['key'])
 });
 });
 })
</script>